package com.imooc.luckymoney.utils;

import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.util.JdbcConstants;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class druidSqlParser {

    public static void main(String[] args) {
        String sql = "SELECT * FROM employee where l_date = '20201130'" +
                "AND job = 'police'";
        String dbType = JdbcConstants.POSTGRESQL;

        String result = SQLUtils.format(sql, dbType);
        
        List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, dbType);

        for (SQLStatement sqlStatement : stmtList) {
            System.out.println(sqlStatement);
        }
    }
}
